MediaSource never emit sourceopen event in React
I came along to this question and used the code provided but i got the error on title. This didn't work on chrome or safari browsers.
const [mediaSource] = useState(new MediaSource())
const videoRef = useRef(null)
// component init
useEffect(() => {
mediaSource.addEventListener('sourceopen')
}, [])
// videoRef changes
useEffect(() => {
videoRef.current.src = URL.createObjectURL(mediaSource)
}, [videoRef])